﻿using RotovapPlatform.Domain.Business.Recipes.Entities;
using RotovapPlatform.Domain.Business.Recipes.Entities.Parameters;
using static RotovapPlatform.Domain.Business.Machine.Enums.ExperimentConfigEnums;
using static RotovapPlatform.Domain.Business.Recipe.Enums.RecipeEnums;
using System.Collections.ObjectModel;

namespace RotovapPlatform.Infrastructure.Common.Data.Seeds;

public static class RecipeSeed
{
	public static async Task SeedAsync(RecipeDbContext context)
	{
		if (!context.Recipes.Any())
		{
			var recipes = new List<RecipeDefinition>
			{
				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "乙醇浓缩实验",
					ExperimentDescription = "使用旋转蒸发仪浓缩乙醇溶液",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "张工",
					CreatedTime = DateTime.Now.AddDays(-5),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "乙醇溶液",
						MaterialLocations = new ObservableCollection<int> { 101, 102 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 60,
								IsStepTemperature = true,
								StepTemperature = 5,
								StepStableTime = 10,
								IsSmartTemperatureJudgment = true,
								RotaryTime = 30,
								RotarySpeed = 120,
								Vacuum = 0.098,
								CondensationTemperature = 10,
								IsCondensationCollect = true,
								IsSampling = true,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = true,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 100,
							CondensationCleaningSpeed = 20,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 200,
							RotaryBottleCleaningTime = 5
						}
					}
				},

				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "乙醇浓缩实验",
					ExperimentDescription = "使用旋转蒸发仪浓缩乙醇溶液",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "张工",
					CreatedTime = DateTime.Now.AddDays(-5),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "乙醇溶液",
						MaterialLocations = new ObservableCollection<int> { 101, 102 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 60,
								IsStepTemperature = true,
								StepTemperature = 5,
								StepStableTime = 10,
								IsSmartTemperatureJudgment = true,
								RotaryTime = 30,
								RotarySpeed = 120,
								Vacuum = 0.098,
								CondensationTemperature = 10,
								IsCondensationCollect = true,
								IsSampling = true,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = true,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 100,
							CondensationCleaningSpeed = 20,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 200,
							RotaryBottleCleaningTime = 5
						}
					}
				},

				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "乙醇浓缩实验",
					ExperimentDescription = "使用旋转蒸发仪浓缩乙醇溶液",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "张工",
					CreatedTime = DateTime.Now.AddDays(-5),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "乙醇溶液",
						MaterialLocations = new ObservableCollection<int> { 101, 102 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 60,
								IsStepTemperature = true,
								StepTemperature = 5,
								StepStableTime = 10,
								IsSmartTemperatureJudgment = true,
								RotaryTime = 30,
								RotarySpeed = 120,
								Vacuum = 0.098,
								CondensationTemperature = 10,
								IsCondensationCollect = true,
								IsSampling = true,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = true,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 100,
							CondensationCleaningSpeed = 20,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 200,
							RotaryBottleCleaningTime = 5
						}
					}
				},
				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "乙醇浓缩实验",
					ExperimentDescription = "使用旋转蒸发仪浓缩乙醇溶液",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "张工",
					CreatedTime = DateTime.Now.AddDays(-5),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "乙醇溶液",
						MaterialLocations = new ObservableCollection<int> { 101, 102 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 60,
								IsStepTemperature = true,
								StepTemperature = 5,
								StepStableTime = 10,
								IsSmartTemperatureJudgment = true,
								RotaryTime = 30,
								RotarySpeed = 120,
								Vacuum = 0.098,
								CondensationTemperature = 10,
								IsCondensationCollect = true,
								IsSampling = true,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = true,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 100,
							CondensationCleaningSpeed = 20,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 200,
							RotaryBottleCleaningTime = 5
						}
					}
				},
				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "乙醇浓缩实验",
					ExperimentDescription = "使用旋转蒸发仪浓缩乙醇溶液",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "张工",
					CreatedTime = DateTime.Now.AddDays(-5),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "乙醇溶液",
						MaterialLocations = new ObservableCollection<int> { 101, 102 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 60,
								IsStepTemperature = true,
								StepTemperature = 5,
								StepStableTime = 10,
								IsSmartTemperatureJudgment = true,
								RotaryTime = 30,
								RotarySpeed = 120,
								Vacuum = 0.098,
								CondensationTemperature = 10,
								IsCondensationCollect = true,
								IsSampling = true,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = true,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 100,
							CondensationCleaningSpeed = 20,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 200,
							RotaryBottleCleaningTime = 5
						}
					}
				},
				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "乙醇浓缩实验",
					ExperimentDescription = "使用旋转蒸发仪浓缩乙醇溶液",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "张工",
					CreatedTime = DateTime.Now.AddDays(-5),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "乙醇溶液",
						MaterialLocations = new ObservableCollection<int> { 101, 102 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 60,
								IsStepTemperature = true,
								StepTemperature = 5,
								StepStableTime = 10,
								IsSmartTemperatureJudgment = true,
								RotaryTime = 30,
								RotarySpeed = 120,
								Vacuum = 0.098,
								CondensationTemperature = 10,
								IsCondensationCollect = true,
								IsSampling = true,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = true,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 100,
							CondensationCleaningSpeed = 20,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 200,
							RotaryBottleCleaningTime = 5
						}
					}
				},
				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "乙醇浓缩实验",
					ExperimentDescription = "使用旋转蒸发仪浓缩乙醇溶液",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "张工",
					CreatedTime = DateTime.Now.AddDays(-5),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "乙醇溶液",
						MaterialLocations = new ObservableCollection<int> { 101, 102 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 60,
								IsStepTemperature = true,
								StepTemperature = 5,
								StepStableTime = 10,
								IsSmartTemperatureJudgment = true,
								RotaryTime = 30,
								RotarySpeed = 120,
								Vacuum = 0.098,
								CondensationTemperature = 10,
								IsCondensationCollect = true,
								IsSampling = true,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = true,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 100,
							CondensationCleaningSpeed = 20,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 200,
							RotaryBottleCleaningTime = 5
						}
					}
				},
				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "乙醇浓缩实验",
					ExperimentDescription = "使用旋转蒸发仪浓缩乙醇溶液",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "张工",
					CreatedTime = DateTime.Now.AddDays(-5),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "乙醇溶液",
						MaterialLocations = new ObservableCollection<int> { 101, 102 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 60,
								IsStepTemperature = true,
								StepTemperature = 5,
								StepStableTime = 10,
								IsSmartTemperatureJudgment = true,
								RotaryTime = 30,
								RotarySpeed = 120,
								Vacuum = 0.098,
								CondensationTemperature = 10,
								IsCondensationCollect = true,
								IsSampling = true,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = true,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 100,
							CondensationCleaningSpeed = 20,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 200,
							RotaryBottleCleaningTime = 5
						}
					}
				},
				new RecipeDefinition
				{
					RecipeId = Guid.NewGuid(),
					ExperimentName = "丙酮回收实验",
					ExperimentDescription = "使用旋转蒸发仪回收废丙酮",
					ExperimentType = ExperimentType.RotaryEvaporation,
					Operator = "李工",
					CreatedTime = DateTime.Now.AddDays(-3),
					RotovapParameters = new RotovapParameters
					{
						RotaryBottleType = RotaryBottleSize.RotaryBottle_1000ml,
						MaterialName = "废丙酮",
						MaterialLocations = new ObservableCollection<int> { 103, 104, 105 },
						ProductParameters = new ObservableCollection<ProductParameters>
						{
							new ProductParameters
							{
								OilTemperature = 45,
								IsStepTemperature = false,
								StepTemperature = 0,
								StepStableTime = 0,
								IsSmartTemperatureJudgment = false,
								RotaryTime = 45,
								RotarySpeed = 150,
								Vacuum = 0.085,
								CondensationTemperature = 5,
								IsCondensationCollect = true,
								IsSampling = false,
								IsBackToCCP = true
							}
						},
						ResidualLiquidParameters = new ResidualLiquidParameters
						{
							IsResidualLiquidCollect = true,
							IsSampling = false,
							IsResidualLiquidBackToCCP = true,
							IsRotaryBottleBackToCCP = true
						},
						CleaningParameters = new CleaningParameters
						{
							IsCondensationClean = true,
							CondensationCleaningSolution = "清水",
							CondensationCleaningVolume = 150,
							CondensationCleaningSpeed = 25,
							IsRotaryBottleClean = true,
							RotaryBottleCleaningSolution = "清水",
							RotaryBottleCleaningVolume = 300,
							RotaryBottleCleaningTime = 8
						}
					}
				}

			};

			await context.Recipes.AddRangeAsync(recipes);
			await context.SaveChangesAsync();
		}
	}
}